// 阿里云发送短信

const Base = require('../base.js');
const Core = require('@alicloud/pop-core');
var client = new Core({
  accessKeyId: 'LTAIidQOqCrubjvb',
  accessKeySecret: 'cqyfDzt4adnbyPjBUOE2BVnD8YJo3h',
  endpoint: 'https://dysmsapi.aliyuncs.com',
  apiVersion: '2017-05-25'
});
module.exports = class extends Base {
    async indexAction() {

        var params = {
            "RegionId": "cn-hangzhou",
            "PhoneNumbers": this.get("phone"),
            "SignName": "中瑞洋洋",
            "TemplateCode": "SMS_461495222",
            "TemplateParam": "{\"code\":\""+this.get("msg")+"\"}"
          }
          
          var requestOption = {
            method: 'POST'
          };
          
          client.request('SendSms', params, requestOption).then((result) => {
            console.log(JSON.stringify(result));
          }, (ex) => {
            console.log(ex);
          })
          this.success("发送成功！")
    }
}